#pragma once
#include "InOut.h"
#include <IStatus.h>

class Point;

class _EXPORT ChessStatus : public ExperientialSystem::IStatus
{
public:
	enum Color
	{
		Black,
		White,
		None
	};

private:
	Color **_colors;
	string _hash;
	ChessStatus::Color _toGo;

	const int ChessSize = 10;
	const int Digit = 2;

public:
	ChessStatus();
	ChessStatus(const vector<Point>& black, const vector<Point>& white,const ChessStatus::Color toGo);
	~ChessStatus();

	virtual string GetHash() const ;

	ChessStatus::Color ToGo() const { return _toGo; };

	void UpdateWinRate(const ChessStatus* status, const double newVal);

	void SetWinRate(const ChessStatus* status, const double newVal);

	bool GetWinRate(const ChessStatus* nextStatus, double& winrate) const;

	vector<Point> GetAllBlacks() const;
	vector<Point> GetAllWhites() const;

	vector<Point> GetAllEmptys() const;

	int GetPieceCount() const;

	//Compare with other chess board and get increased black and white and decrease black and white piece.
	//Increment means pieces in me are more than other.
	void Compare(const ChessStatus* other,
		vector<Point>& increBlack,
		vector<Point>& increWhite,
		vector<Point>& decreBlack,
		vector<Point>& decreWhite);

	virtual void Write(ofstream& out) const override;

	virtual void Read(ifstream& in) override;


private:

	void InitColors();

	string ComputeHash() const;
};

class _EXPORT Point
{
	int _x;
	int _y;
public:
	Point() :_x(0), _y(0) {};
	Point(int x, int y) :_x(x), _y(y) {};
	~Point() {};

	int X()const { return _x; }
	int Y()const { return _y; }
};

